/**
 * File: ChunkReader.java
 * Created by: mhaimel
 * Created on: Aug 8, 2011
 * CVS:  $Id: ChunkReader.java 1.0 Aug 8, 2011 1:43:35 PM mhaimel Exp $
 */
package uk.ac.ebi.curtain.utils.file.impl;

import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * @author mhaimel
 *
 */
public interface ChunkReader extends Closeable {
	
	/**
	 * Includes an whole entry (incl. new-lines at the end)
	 * @return NULL if it reached EOF
	 * @throws IOException if reached unexpected EOF or other IO problems
	 */
	String nextEntry() throws IOException;
	
	/**
	 * Includes an whole entry (incl. new-lines at the end)
	 * @return NULL if it reached EOF
	 * @throws IOException if reached unexpected EOF or other IO problems
	 */
	byte[] nextEntryByteArray() throws IOException;
	
	
	/**
	 * Includes an whole entry (incl. new-lines at the end) <br>
	 * Reuse of {@link ByteBuffer} e.g. <br>
	 * {@link ByteBuffer} bb = {@link ByteBuffer#allocate(int)}; <br>
	 * while( (bb = {@link #nextEntryByteArray(bb)}) != null){ <br>
	 *   out.write(bb);<br>
	 * }<br>
	 * @param bb {@link ByteBuffer} to be filled
	 * @return NULL if it reached EOF
	 * @throws IOException if reached unexpected EOF or other IO problems
	 */
	ByteBuffer nextEntryByteArray(ByteBuffer bb) throws IOException;

}
